import instance from '.';
// 获取登录参数
interface ILoginParamsType {
  username: string;
  password: string;
}
interface ILoginRes {
  token: string;
  tokenHead: string;
}

// 获取用户列表参数
interface IRoleParamsType {
  keyword?: string;
  pageNum?: number;
  pageSize?: number;
}

// 获取用户信息列表

interface adminResType {
  icon: string;
  menus: adminMenusResType[];
  roles: string[];
  username: string;
}
// 修改用户状态
interface IAdminUpdateStatus {
  id: number;
  status: number;
}

//用户注册
interface IAdminRegisterParams {
  email: string;
  nickName: string;
  note: string;
  password: string;
  username: string;
  icon: string;
}
export const LoginApi = (params: ILoginParamsType): IPR<ILoginRes> =>
  instance.post('/admin/login', params);
export const getAdminApi = (): IPR<adminResType> => instance.get('/admin/info');
export const getAdminListApi = (
  params: IRoleParamsType,
): IPR<IgetListRes<IAdminListResArr>> =>
  instance.get('/admin/list', { params });

export const getAdminUpdateStatus = (params: IAdminUpdateStatus): IPR<number> =>
  instance.post(
    `/admin/updateStatus/${params.id}?status=${params.status}`,
    params,
  );
export const getAdminRegister = (params: IAdminRegisterParams): IPR<any> =>
  instance.post('/admin/register', params);
export const adminUpdate = (params: IAdminListResArr): IPR<any> =>
  instance.post(`/admin/update/${params.id}`, params);
